<html>
<head>
<title>main.ets</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
.s0 { color: #bbb529;}
.s1 { color: #a9b7c6;}
.s2 { color: #faa23d;}
.s3 { color: #e2da90;}
.s4 { color: #b3e54c;}
.s5 { color: #db7e9b;}
.s6 { color: #aa7dfc;}
</style>
</head>
<body bgcolor="#2b2b2b">
<table CELLSPACING=0 CELLPADDING=5 COLS=1 WIDTH="100%" BGCOLOR="#606060" >
<tr><td><center>
<font face="Arial, Helvetica" color="#000000">
main.ets</font>
</center></td></tr></table>
<pre><span class="s0">@</span><span class="s1">Entry</span>
<span class="s0">@</span><span class="s1">Component</span>
<span class="s1">export struct main </span><span class="s2">{</span>
  <span class="s0">@</span><span class="s1">State currentTab</span><span class="s3">: </span><span class="s1">number </span><span class="s3">= </span><span class="s4">0</span>

  <span class="s1">private tabs</span><span class="s3">: </span><span class="s1">string</span><span class="s5">[] </span><span class="s3">= </span><span class="s5">[</span><span class="s6">'热点'</span><span class="s3">, </span><span class="s6">'团购'</span><span class="s3">, </span><span class="s6">'商城'</span><span class="s3">, </span><span class="s6">'武汉'</span><span class="s3">,</span><span class="s6">'关注'</span><span class="s3">, </span><span class="s6">'推荐'</span><span class="s5">]</span>

  <span class="s1">build</span><span class="s5">() </span><span class="s2">{</span>
    <span class="s1">Column</span><span class="s5">() </span><span class="s2">{</span>
      <span class="s1">Row</span><span class="s5">(</span><span class="s2">{</span><span class="s1">space</span><span class="s3">:</span><span class="s4">8</span><span class="s2">}</span><span class="s5">) </span><span class="s2">{</span>
        <span class="s1">Text</span><span class="s5">(</span><span class="s6">'≡'</span><span class="s5">)</span><span class="s3">.</span><span class="s1">fontSize</span><span class="s5">(</span><span class="s4">22</span><span class="s5">)</span><span class="s3">.</span><span class="s1">fontColor</span><span class="s5">(</span><span class="s6">'#222'</span><span class="s5">)</span><span class="s3">.</span><span class="s1">margin</span><span class="s5">(</span><span class="s2">{ </span><span class="s1">right</span><span class="s3">: </span><span class="s4">12 </span><span class="s2">}</span><span class="s5">)</span>
        <span class="s1">ForEach</span><span class="s5">(</span><span class="s1">this</span><span class="s3">.</span><span class="s1">tabs</span><span class="s3">, </span><span class="s5">(</span><span class="s1">tab</span><span class="s3">: </span><span class="s1">string</span><span class="s3">, </span><span class="s1">index</span><span class="s3">: </span><span class="s1">number</span><span class="s5">) </span><span class="s3">=&gt; </span><span class="s2">{</span>
          <span class="s1">Column</span><span class="s5">() </span><span class="s2">{</span>
            <span class="s1">Row</span><span class="s5">() </span><span class="s2">{</span>
              <span class="s1">Text</span><span class="s5">(</span><span class="s1">tab</span><span class="s5">)</span>
                <span class="s3">.</span><span class="s1">fontSize</span><span class="s5">(</span><span class="s4">15</span><span class="s5">)</span>
                <span class="s3">.</span><span class="s1">fontColor</span><span class="s5">(</span><span class="s1">this</span><span class="s3">.</span><span class="s1">currentTab </span><span class="s3">=== </span><span class="s1">index </span><span class="s3">? </span><span class="s6">'#222' </span><span class="s3">: </span><span class="s6">'#888'</span><span class="s5">)</span>
                <span class="s3">.</span><span class="s1">onClick</span><span class="s5">(() </span><span class="s3">=&gt; </span><span class="s2">{</span>
                  <span class="s1">this</span><span class="s3">.</span><span class="s1">currentTab </span><span class="s3">= </span><span class="s1">index</span>
                <span class="s2">}</span><span class="s5">)</span>

            <span class="s2">}</span>
            <span class="s1">if </span><span class="s5">(</span><span class="s1">this</span><span class="s3">.</span><span class="s1">currentTab </span><span class="s3">=== </span><span class="s1">index</span><span class="s5">) </span><span class="s2">{</span>
              <span class="s1">Row</span><span class="s5">()</span><span class="s3">.</span><span class="s1">height</span><span class="s5">(</span><span class="s4">2</span><span class="s5">)</span><span class="s3">.</span><span class="s1">width</span><span class="s5">(</span><span class="s4">24</span><span class="s5">)</span><span class="s3">.</span><span class="s1">backgroundColor</span><span class="s5">(</span><span class="s6">'#222'</span><span class="s5">)</span><span class="s3">.</span><span class="s1">margin</span><span class="s5">(</span><span class="s2">{ </span><span class="s1">top</span><span class="s3">: </span><span class="s4">2 </span><span class="s2">}</span><span class="s5">)</span>
            <span class="s2">}</span>
          <span class="s2">}</span><span class="s3">.</span><span class="s1">margin</span><span class="s5">(</span><span class="s2">{ </span><span class="s1">right</span><span class="s3">: </span><span class="s4">12 </span><span class="s2">}</span><span class="s5">)</span>
        <span class="s2">}</span><span class="s5">)</span>

        <span class="s1">Text</span><span class="s5">(</span><span class="s6">'🔍'</span><span class="s5">)</span><span class="s3">.</span><span class="s1">fontSize</span><span class="s5">(</span><span class="s4">20</span><span class="s5">)</span><span class="s3">.</span><span class="s1">fontColor</span><span class="s5">(</span><span class="s6">'#222'</span><span class="s5">)</span>
      <span class="s2">}</span>
      <span class="s3">.</span><span class="s1">height</span><span class="s5">(</span><span class="s4">48</span><span class="s5">)</span>
      <span class="s3">.</span><span class="s1">alignItems</span><span class="s5">(</span><span class="s1">VerticalAlign</span><span class="s3">.</span><span class="s1">Center</span><span class="s5">)</span>
      <span class="s3">.</span><span class="s1">padding</span><span class="s5">(</span><span class="s2">{ </span><span class="s1">left</span><span class="s3">: </span><span class="s4">12</span><span class="s3">, </span><span class="s1">right</span><span class="s3">: </span><span class="s4">12 </span><span class="s2">}</span><span class="s5">)</span>
      <span class="s3">.</span><span class="s1">backgroundColor</span><span class="s5">(</span><span class="s6">'#fff'</span><span class="s5">)</span>
      <span class="s1">if </span><span class="s5">(</span><span class="s1">this</span><span class="s3">.</span><span class="s1">currentTab </span><span class="s3">=== </span><span class="s4">0</span><span class="s5">) </span><span class="s2">{</span>
        <span class="s1">Text</span><span class="s5">(</span><span class="s6">'热点内容'</span><span class="s5">)</span><span class="s3">.</span><span class="s1">fontSize</span><span class="s5">(</span><span class="s4">20</span><span class="s5">)</span><span class="s3">.</span><span class="s1">fontColor</span><span class="s5">(</span><span class="s6">'#222'</span><span class="s5">)</span><span class="s3">.</span><span class="s1">margin</span><span class="s5">(</span><span class="s2">{ </span><span class="s1">top</span><span class="s3">: </span><span class="s4">20 </span><span class="s2">}</span><span class="s5">)</span>
      <span class="s2">} </span><span class="s1">else if </span><span class="s5">(</span><span class="s1">this</span><span class="s3">.</span><span class="s1">currentTab </span><span class="s3">=== </span><span class="s4">1</span><span class="s5">) </span><span class="s2">{</span>
        <span class="s1">Text</span><span class="s5">(</span><span class="s6">'团购内容'</span><span class="s5">)</span><span class="s3">.</span><span class="s1">fontSize</span><span class="s5">(</span><span class="s4">20</span><span class="s5">)</span><span class="s3">.</span><span class="s1">fontColor</span><span class="s5">(</span><span class="s6">'#222'</span><span class="s5">)</span><span class="s3">.</span><span class="s1">margin</span><span class="s5">(</span><span class="s2">{ </span><span class="s1">top</span><span class="s3">: </span><span class="s4">20 </span><span class="s2">}</span><span class="s5">)</span>
      <span class="s2">} </span><span class="s1">else if </span><span class="s5">(</span><span class="s1">this</span><span class="s3">.</span><span class="s1">currentTab </span><span class="s3">=== </span><span class="s4">2</span><span class="s5">) </span><span class="s2">{</span>
        <span class="s1">Text</span><span class="s5">(</span><span class="s6">'商城内容'</span><span class="s5">)</span><span class="s3">.</span><span class="s1">fontSize</span><span class="s5">(</span><span class="s4">20</span><span class="s5">)</span><span class="s3">.</span><span class="s1">fontColor</span><span class="s5">(</span><span class="s6">'#222'</span><span class="s5">)</span><span class="s3">.</span><span class="s1">margin</span><span class="s5">(</span><span class="s2">{ </span><span class="s1">top</span><span class="s3">: </span><span class="s4">20 </span><span class="s2">}</span><span class="s5">)</span>
      <span class="s2">} </span><span class="s1">else if </span><span class="s5">(</span><span class="s1">this</span><span class="s3">.</span><span class="s1">currentTab </span><span class="s3">=== </span><span class="s4">3</span><span class="s5">) </span><span class="s2">{</span>
        <span class="s1">Text</span><span class="s5">(</span><span class="s6">'武汉'</span><span class="s5">)</span><span class="s3">.</span><span class="s1">fontSize</span><span class="s5">(</span><span class="s4">20</span><span class="s5">)</span><span class="s3">.</span><span class="s1">fontColor</span><span class="s5">(</span><span class="s6">'#222'</span><span class="s5">)</span><span class="s3">.</span><span class="s1">margin</span><span class="s5">(</span><span class="s2">{ </span><span class="s1">top</span><span class="s3">: </span><span class="s4">20 </span><span class="s2">}</span><span class="s5">)</span>

      <span class="s2">}</span>
      <span class="s1">else if </span><span class="s5">(</span><span class="s1">this</span><span class="s3">.</span><span class="s1">currentTab </span><span class="s3">=== </span><span class="s4">4</span><span class="s5">) </span><span class="s2">{</span>
        <span class="s1">Text</span><span class="s5">(</span><span class="s6">'关注内容'</span><span class="s5">)</span><span class="s3">.</span><span class="s1">fontSize</span><span class="s5">(</span><span class="s4">20</span><span class="s5">)</span><span class="s3">.</span><span class="s1">fontColor</span><span class="s5">(</span><span class="s6">'#222'</span><span class="s5">)</span><span class="s3">.</span><span class="s1">margin</span><span class="s5">(</span><span class="s2">{ </span><span class="s1">top</span><span class="s3">: </span><span class="s4">20 </span><span class="s2">}</span><span class="s5">)</span>
      <span class="s2">}</span><span class="s1">else if </span><span class="s5">(</span><span class="s1">this</span><span class="s3">.</span><span class="s1">currentTab </span><span class="s3">=== </span><span class="s4">5</span><span class="s5">) </span><span class="s2">{</span>
        <span class="s1">Text</span><span class="s5">(</span><span class="s6">'推荐内容'</span><span class="s5">)</span><span class="s3">.</span><span class="s1">fontSize</span><span class="s5">(</span><span class="s4">20</span><span class="s5">)</span><span class="s3">.</span><span class="s1">fontColor</span><span class="s5">(</span><span class="s6">'#222'</span><span class="s5">)</span><span class="s3">.</span><span class="s1">margin</span><span class="s5">(</span><span class="s2">{ </span><span class="s1">top</span><span class="s3">: </span><span class="s4">20 </span><span class="s2">}</span><span class="s5">)</span>
      <span class="s2">}</span>
    <span class="s2">}</span><span class="s3">.</span><span class="s1">width</span><span class="s5">(</span><span class="s6">&quot;100%&quot;</span><span class="s5">)</span><span class="s3">.</span><span class="s1">height</span><span class="s5">(</span><span class="s6">&quot;100%&quot;</span><span class="s5">)</span>
  <span class="s2">}</span>
<span class="s2">}</span></pre>
</body>
</html>